/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef BOLPEAKTHEOMSMSFACTORY_H
#define BOLPEAKTHEOMSMSFACTORY_H
#include <map>
#include <vector>
#include <string>

#include "peptide.h"
#include "spectrum.h"
#include "peaktheomsms.h"
#include "chargemapper.h"

using namespace std;
namespace bol {

/**
  A virtual class for generation of theoratical mass

  @todo see if we must create some more leaborated structure for a series thant just the name
  
  @author Alexandre Masselot,,, <alex@alex-laptop>
 */
  class PeakTheoMsMsFactory{
    private:
      static map<string, const unsigned int>m_series2index;
      static vector<string>m_series;
      ChargeMapper m_chargeMapper;
    public:
      class ChargedSeries{
        public:
          const unsigned int z;
          const unsigned int index;
          ChargedSeries(const unsigned int index, const unsigned int z):index(index),z(z){}
      };
      PeakTheoMsMsFactory();

      ~PeakTheoMsMsFactory();

      /**
       * given a series name, return the local index under wich is stored the series. If this series is new, it creates a new entry into the table
       * @param series
       * @return
       */
      static const unsigned int series2index(const string& series);
      
      /**
       * given an index, return the series name (y, y++, y-NH3 etc.)
       * @param index
       * @return
       */
      static const string& index2series(const unsigned int index);

      /**
       *
       * @return  the number or registrated series
       */
      static const unsigned int nbSeries(){
        return m_series.size();
      }

      /**
       *
       * @param pept
       * @param spectrum
       * @param charge the charge we must build the parameter for (for exmaplke, if the precrusor is >=2 and y is registrated, we want to build y and y++)
       * @param showDescription
       */
      virtual void computeTheoMasses(const Peptide& pept, Spectrum<PeakTheoMsms*>& spectrum,
                                     const unsigned int charge,
                                     const bool showDescription)const=0;

      void setChargeMapper(const ChargeMapper& theValue) {
        m_chargeMapper = theValue;
      }
  

      ChargeMapper chargeMapper() const {
        return m_chargeMapper;
      }
  
  };

}

#endif
